package com.e3mall.controller;

import com.e3mall.utils.DataGridPageResult;
import com.e3mall.interfaces.TbItemService;
import com.e3mall.manage.pojo.TbItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @作者: Vgger
 * @E-Mail:1055106789@qq.com
 * @描述:
 * @修改时间: Created in 21:37 2018/4/21
 */
@Controller
public class ItemController {

    //    注入service
    @Autowired
    private TbItemService itemService;

    @RequestMapping("/item/{itemId}")
    @ResponseBody
    public TbItem getItemById(@PathVariable Long itemId) {
        return itemService.getItemById(itemId);
    }

    @RequestMapping("/")
    public String toIndexPage() {
        return "index";
    }

    @RequestMapping("{page}")
    public String itemList(@PathVariable String page) {
        return page;
    }

    @RequestMapping("/item/list")
    @ResponseBody
    public DataGridPageResult itemList(Integer page, Integer rows) {
        return itemService.getPage(page, rows);
    }

}
